package com.xg.controller.boss;

import com.xg.common.constant.CommonStatusEnum;
import com.xg.common.request.SeriesReq;
import com.xg.common.result.ApiResult;
import com.xg.common.util.Func;
import com.xg.common.util.PageUtil;
import com.xg.common.util.PageUtilHelper;
import com.xg.entity.UsedCarBrand;
import com.xg.entity.UsedCarSeries;
import com.xg.service.IUsedCarSeriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SeriesController {

    @Autowired
    private IUsedCarSeriesService seriesService;

    @GetMapping("/series/list")
    ApiResult<List<UsedCarSeries>> findUsedCarSeriesList(){
        List<UsedCarSeries> list = seriesService.list();
        return ApiResult.success(list);
    }

    @RequestMapping("/series/queryPageList")
    ApiResult<PageUtil<UsedCarSeries>> queryPageList(@RequestBody SeriesReq seriesReq) {
        return seriesService.querySeriesList(seriesReq);
    }

    @RequestMapping("/series/delete")
    ApiResult deleteSerices(@RequestParam("ids") List<Integer> ids) {
        return seriesService.deleteSerices(ids);
    }

    @RequestMapping("/series/info")
    ApiResult<UsedCarSeries> selectSeriesInfo(@RequestParam("id") Integer seriesId) {
        return seriesService.selectSeriesInfo(seriesId);
    }

    @RequestMapping("/series/save")
    ApiResult saveSeries(@RequestBody UsedCarSeries usedCarSeries) {
        return seriesService.saveSeries(usedCarSeries);
    }

    @GetMapping("/series/findListByBrandId")
    ApiResult<List<UsedCarSeries>> findListByBrandId(@RequestParam("brandId") Integer brandId){
        return seriesService.findListByBrandId(brandId);
    }

    @GetMapping("/series/findBrandBySeriesId")
    ApiResult<UsedCarBrand> findBrandBySeriesId(@RequestParam("seriesId") Integer seriesId){
        return seriesService.findBrandBySeriesId(seriesId);
    }
}
